package holdem.Rulegui;

import java.io.Serializable;
import java.util.Vector;

import holdem.ListInt;


public abstract  class Code implements Serializable  {
	
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 6903847945567315611L;
	public abstract ListInt parse(GeneticCode code ,ListInt Wmemeory );
	
	/**
	 * Note Delimiter is U
	 * @param s
	 * @return
	 */
	public static  Code load(String s){
		Code Rval = null;
		for(int i = 0 ; i < s.length();i++ ){
			//TreeCoode
			if(s.charAt(i) == 'T'){
				
				Vector<Integer> codet = new Vector<Integer>();
				
				//j is equal to 1 T is a preidentifyer
				for(int j = 1; j < s.split("T").length; j++){
					int temp =Integer.parseInt( s.split("T")[j]) ;
					codet.add(temp);
					
				}
				return new TreeCode(codet);
			
			
			}
			//GeneCode
			if(s.charAt(i) == 'G'){
				return new GeneCode( 
						Integer.parseInt(
								 s.substring(i+1, s.length())
						)
						);
			
			}
			
		}
		return Rval;
	}
	public abstract  String saveString();
		
}
